<template>
  <!--登陆表单，纯样式-->
  <UserLayout>
    <template>
      <el-form label-position="right" label-width="80px" :model="form">
        <el-form-item label="用户名">
          <el-input @change="afterUpdata" v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input type="password" @change="afterUpdata" v-model="form.pass"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button v-if="isUser" @click="$router.push('/user/register')">注册</el-button>
          <el-button @click="onSubmit" type="primary">登录</el-button>
        </el-form-item>
      </el-form>
    </template>
  </UserLayout>
</template>

<script>
import UserLayout from "@/components/form/UserLayout.vue";

export default {
  props: {
    isUser: Boolean,
    value: {
      name: String,
      pass: String
    }
  },
  components: {
    UserLayout
  },
  data() {
    return {
      form: {}
    };
  },
  mounted() {
    this.form = this.value;
  },
  methods: {
    afterUpdata() {
      this.$emit("input", this.form);
    },
    onSubmit() {
      this.$emit("submit", null);
    }
  }
};
</script>